package com.xinruke.hostels.systemmanage.controller;

import com.xinruke.hostels.common.controller.BaseController;
import com.xinruke.hostels.common.vo.ResultVO;
import com.xinruke.hostels.common.vo.query.RowsDataVO;
import com.xinruke.hostels.system.manage.interfaces.dto.*;
import com.xinruke.hostels.systemmanage.service.FloorService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

/**
 * 楼层管理
 *
 * @author Jinz
 * @date 2019-06-26 16:23
 */
@RestController
@RequestMapping("/floor")
@Api(tags = "楼层")
public class FloorController extends BaseController {

    @Autowired
    private FloorService floorService;

    @PostMapping("/add")
    @ApiOperation("添加楼层")
    public ResultVO add(@Valid @RequestBody FloorAddQueryDTO floorAddQueryDTO) {
        return floorService.add(floorAddQueryDTO);
    }

    @PostMapping("/modify")
    @ApiOperation("修改楼层")
    public ResultVO modify(@Valid @RequestBody FloorUpdateQueryDTO floorUpdateQueryDTO) {
        return floorService.modify(floorUpdateQueryDTO);
    }

    @PostMapping("/del")
    @ApiOperation("删除楼层")
    public ResultVO delete(@Valid @RequestBody FloorDelQueryDTO floorDelQueryDTO) {
        return floorService.delete(floorDelQueryDTO);
    }

    @PostMapping("/detail")
    @ApiOperation("楼层详情")
    public ResultVO<FloorDetailQueryResultDTO> detail(@Valid @RequestBody FloorDetailQueryDTO floorDetailQueryDTO) {
        return floorService.detail(floorDetailQueryDTO);
    }

    @PostMapping("/floors")
    @ApiOperation("楼层列表")
    public ResultVO<RowsDataVO<FloorDetailQueryResultDTO>> floors(@Valid @RequestBody FloorsQueryDTO floorsQueryDTO) {
        return floorService.floors(floorsQueryDTO);
    }
}
